<template>
	<view class="wrap">
		<u-cell-item title="页面边距" :arrow="false">
			<u-radio-group v-model="readSetting.pagePadding" @change="onChange" slot="right-icon">
				<u-radio name="0"> 无 </u-radio>
				<u-radio name="20"> 小 </u-radio>
				<u-radio name="40"> 中 </u-radio>
				<u-radio name="80"> 大 </u-radio>
			</u-radio-group>
		</u-cell-item>
		<u-cell-item title="段落距离" :arrow="false">
			<u-radio-group v-model="readSetting.sectionDistance" @change="onChange" slot="right-icon">
				<u-radio name="0"> 小 </u-radio>
				<u-radio name="1"> 中 </u-radio>
				<u-radio name="2"> 大 </u-radio>
			</u-radio-group>
		</u-cell-item>
		<u-cell-item title="行间距离" :arrow="false">
			<u-radio-group v-model="readSetting.lineDistance" @change="onChange" slot="right-icon">
				<u-radio name="30"> 小 </u-radio>
				<u-radio name="38"> 中 </u-radio>
				<u-radio name="60"> 大 </u-radio>
			</u-radio-group>
		</u-cell-item>
		<u-cell-item title="启动时自动打开最近阅读的书籍" :arrow="false">
			<u-switch slot="right-icon" v-model="readSetting.openLastRead" @change="onChange"></u-switch>
		</u-cell-item>
		<u-cell-item title="阅读时屏幕常亮" :arrow="false">
			<u-switch slot="right-icon" v-model="readSetting.lightForever" @change="onChange"></u-switch>
		</u-cell-item>
		<u-cell-item title="深色模式" :arrow="false">
			<u-switch slot="right-icon" v-model="readSetting.isDarkMode" @change="onChange"></u-switch>
		</u-cell-item>
	</view>
</template>

<script>
	import {
		mapState
	} from 'vuex'
	export default {
		computed: {
			...mapState({
				readSetting: state => state.setting.readSetting
			})
		},
		methods: {
			onChange: _.throttle(function(e) {
				this.$store.commit('UPDATE_READ_SETTING')
			}, 200, {
				'trailing': false
			})
		},
		created(){
			console.log(this.$store)
		}
	};
</script>

<style lang="scss" scoped>

</style>
